package com.ttai.presenter.activity;

import android.app.Application;
import android.content.Intent;
import android.widget.Toast;

import com.google.gson.JsonObject;
import com.ttai.model.net.ResponseInfo;
import com.ttai.presenter.base.BasePresenter;
import com.ttai.ui.activity.ChooseId;
import com.ttai.ui.activity.UserHomePage;

import retrofit2.Call;

public class QrLoginPresenter extends BasePresenter{
    ChooseId chooseId;

    public QrLoginPresenter(ChooseId chooseId) {
        this.chooseId = chooseId;
    }

    @Override
    protected void showError(String message) {
        Toast.makeText(chooseId,message,Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void parseJson(JsonObject json) {
        Toast.makeText(chooseId,"确认成功",Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(chooseId, UserHomePage.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        chooseId.startActivity(intent);
    }
    public void qrLogin(String accountFlag,String appId,String token,String qrId){
        Call<ResponseInfo> qrLogin = responseInfoApi.qrLogin(accountFlag, appId, token, qrId);
        qrLogin.enqueue(new CallBackAdapter());
    }
}
